package com.baiyinet.rest;

import com.baiyinet.BuildConfig;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

/**
 * @author J.Huang
 * @version 1.0
 * @since 17/8/17
 */

public class UnSafeHostnameVerifier implements HostnameVerifier {
    @Override
    public boolean verify(String hostname, SSLSession session) {
        // 自行添加判断逻辑，true->Safe，false->unsafe

        String serverHostname = BuildConfig.ENDPOINT.replace("https://", "").replace("/", "");

        final String[] hostUrls = new String[]{serverHostname};

        boolean ret = false;
        for (String host : hostUrls) {
            if (host.equalsIgnoreCase(hostname)) {
                ret = true;
            }
        }
        return ret;
    }
}
